package net.aiion.weave.impl.resources;

import net.aiion.weave.spi.naming.annotations.Named;
import net.aiion.weave.spi.naming.annotations.NotScoped;
import net.aiion.weave.spi.resources.Resource;
import net.aiion.weave.spi.resources.ResourceFactory;
import net.aiion.weave.spi.resources.ResourceService;

@NotScoped
@Named
public class ResourceServiceImpl implements ResourceService
{
    public ResourceServiceImpl() {
    }

    @Override
    public Resource findResource(final String aResourceName) {
        return ResourceFactory.getInstance().createResource(aResourceName);
    }

    @Override
    public Resource findResource(final Package aPackage, final String aResourceName) {
        return findResource(aPackage.getName().replace('.', '/') + '/' + aResourceName);
    }

    @Override
    public Resource findResource(final Class<?> aClass, final String aResourceName) {
        return findResource(aClass.getName().replace('.', '/') + '/' + aResourceName);
    }

    @Override
    public Resource findResource(final Object aObject, final String aResourceName) {
        return findResource(aObject.getClass(), aResourceName);
    }
}
